package com.apollographql.apollo.internal.response;

//import HOS.exifinterface.media.ExifInterface;
import com.apollographql.apollo.api.CustomTypeAdapter;
import com.apollographql.apollo.api.CustomTypeValue;
import com.apollographql.apollo.api.Operation;
import com.apollographql.apollo.api.ResponseField;
import com.apollographql.apollo.api.ScalarType;
import com.apollographql.apollo.api.ScalarTypeAdapters;
import com.apollographql.apollo.api.internal.FieldValueResolver;
import com.apollographql.apollo.api.internal.ResolveDelegate;
import com.apollographql.apollo.api.internal.ResponseReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.kt.Metadata;
import com.kt.TypeCastException;
import com.kt.collections.CollectionsKt;
import com.kt.jvm.functions.Function1;
import com.kt.jvm.internal.Intrinsics;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0001\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0006\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010 \n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0007\u0018\u0000*\u0004\b\u0000\u0010\u00012\u00020\u0002:\u0001<B9\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\u0006\u0010\u0005\u001a\u00028\u0000\u0012\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00028\u00000\u0007\u0012\u0006\u0010\b\u001a\u00020\t\u0012\f\u0010\n\u001a\b\u0012\u0004\u0012\u00028\u00000\u000b¢\u0006\u0002\u0010\fJ\u001a\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001d2\b\u0010\u001e\u001a\u0004\u0018\u00010\u0019H\u0002J\u0010\u0010\u001f\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001dH\u0002J\u0017\u0010 \u001a\u0004\u0018\u00010!2\u0006\u0010\u001c\u001a\u00020\u001dH\u0016¢\u0006\u0002\u0010\"J!\u0010#\u001a\u0004\u0018\u0001H$\"\b\b\u0001\u0010$*\u00020\u00192\u0006\u0010\u001c\u001a\u00020%H\u0016¢\u0006\u0002\u0010&J\u0017\u0010'\u001a\u0004\u0018\u00010(2\u0006\u0010\u001c\u001a\u00020\u001dH\u0016¢\u0006\u0002\u0010)J/\u0010*\u001a\u0004\u0018\u0001H$\"\b\b\u0001\u0010$*\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001d2\f\u0010+\u001a\b\u0012\u0004\u0012\u0002H$0,H\u0016¢\u0006\u0002\u0010-J\u0017\u0010.\u001a\u0004\u0018\u00010/2\u0006\u0010\u001c\u001a\u00020\u001dH\u0016¢\u0006\u0002\u00100J2\u00101\u001a\f\u0012\u0006\u0012\u0004\u0018\u0001H$\u0018\u000102\"\b\b\u0001\u0010$*\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001d2\f\u00103\u001a\b\u0012\u0004\u0012\u0002H$04H\u0016J\u0017\u00105\u001a\u0004\u0018\u0001062\u0006\u0010\u001c\u001a\u00020\u001dH\u0016¢\u0006\u0002\u00107J/\u00108\u001a\u0004\u0018\u0001H$\"\b\b\u0001\u0010$*\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001d2\f\u0010+\u001a\b\u0012\u0004\u0012\u0002H$0,H\u0016¢\u0006\u0002\u0010-J\u0012\u00109\u001a\u0004\u0018\u00010\u00182\u0006\u0010\u001c\u001a\u00020\u001dH\u0016J\u0010\u0010:\u001a\u00020!2\u0006\u0010\u001c\u001a\u00020\u001dH\u0002J\u001a\u0010;\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001d2\b\u0010\u001e\u001a\u0004\u0018\u00010\u0019H\u0002R\u001a\u0010\u0006\u001a\b\u0012\u0004\u0012\u00028\u00000\u0007X\u0004¢\u0006\b\n\u0000\u001a\u0004\b\r\u0010\u000eR\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R\u0010\u0010\u0005\u001a\u00028\u0000X\u0004¢\u0006\u0004\n\u0002\u0010\u0011R\u001a\u0010\n\u001a\b\u0012\u0004\u0012\u00028\u00000\u000bX\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0012\u0010\u0013R\u0014\u0010\b\u001a\u00020\tX\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0014\u0010\u0015R\u001c\u0010\u0016\u001a\u0010\u0012\u0004\u0012\u00020\u0018\u0012\u0006\u0012\u0004\u0018\u00010\u00190\u0017X\u0004¢\u0006\u0002\n\u0000¨\u0006="}, d2 = {"Lcom/apollographql/apollo/internal/response/RealResponseReader;", "R", "Lcom/apollographql/apollo/api/internal/ResponseReader;", "operationVariables", "Lcom/apollographql/apollo/api/Operation$Variables;", "recordSet", "fieldValueResolver", "Lcom/apollographql/apollo/api/internal/FieldValueResolver;", "scalarTypeAdapters", "Lcom/apollographql/apollo/api/ScalarTypeAdapters;", "resolveDelegate", "Lcom/apollographql/apollo/api/internal/ResolveDelegate;", "(Lcom/apollographql/apollo/api/Operation$Variables;Ljava/lang/Object;Lcom/apollographql/apollo/api/internal/FieldValueResolver;Lcom/apollographql/apollo/api/ScalarTypeAdapters;Lcom/apollographql/apollo/api/internal/ResolveDelegate;)V", "getFieldValueResolver$apollo_runtime", "()Lcom/apollographql/apollo/api/internal/FieldValueResolver;", "getOperationVariables", "()Lcom/apollographql/apollo/api/Operation$Variables;", "Ljava/lang/Object;", "getResolveDelegate$apollo_runtime", "()Lcom/apollographql/apollo/api/internal/ResolveDelegate;", "getScalarTypeAdapters$apollo_runtime", "()Lcom/apollographql/apollo/api/ScalarTypeAdapters;", "variableValues", "", "", "", "checkValue", "", "field", "Lcom/apollographql/apollo/api/ResponseField;", "value", "didResolve", "readBoolean", "", "(Lcom/apollographql/apollo/api/ResponseField;)Ljava/lang/Boolean;", "readCustomType", "ExifInterface.GPS_DIRECTION_TRUE", "Lcom/apollographql/apollo/api/ResponseField$CustomTypeField;", "(Lcom/apollographql/apollo/api/ResponseField$CustomTypeField;)Ljava/lang/Object;", "readDouble", "", "(Lcom/apollographql/apollo/api/ResponseField;)Ljava/lang/Double;", "readFragment", "objectReader", "Lcom/apollographql/apollo/api/internal/ResponseReader$ObjectReader;", "(Lcom/apollographql/apollo/api/ResponseField;Lcom/apollographql/apollo/api/internal/ResponseReader$ObjectReader;)Ljava/lang/Object;", "readInt", "", "(Lcom/apollographql/apollo/api/ResponseField;)Ljava/lang/Integer;", "readList", "", "listReader", "Lcom/apollographql/apollo/api/internal/ResponseReader$ListReader;", "readLong", "", "(Lcom/apollographql/apollo/api/ResponseField;)Ljava/lang/Long;", "readObject", "readString", "shouldSkip", "willResolve", "ListItemReader", "apollo-runtime"}, k = 1, mv = {1, 4, 0})
/* compiled from: RealResponseReader.kt */
public final class RealResponseReader<R> implements ResponseReader {
    private final FieldValueResolver<R> fieldValueResolver;
    private final Operation.Variables operationVariables;
    private final R recordSet;
    private final ResolveDelegate<R> resolveDelegate;
    private final ScalarTypeAdapters scalarTypeAdapters;
    private final Map<String, Object> variableValues;

    public RealResponseReader(Operation.Variables operationVariables2, R r, FieldValueResolver<R> fieldValueResolver2, ScalarTypeAdapters scalarTypeAdapters2, ResolveDelegate<R> resolveDelegate2) {
        Intrinsics.checkParameterIsNotNull(operationVariables2, "operationVariables");
        Intrinsics.checkParameterIsNotNull(fieldValueResolver2, "fieldValueResolver");
        Intrinsics.checkParameterIsNotNull(scalarTypeAdapters2, "scalarTypeAdapters");
        Intrinsics.checkParameterIsNotNull(resolveDelegate2, "resolveDelegate");
        this.operationVariables = operationVariables2;
        this.recordSet = r;
        this.fieldValueResolver = fieldValueResolver2;
        this.scalarTypeAdapters = scalarTypeAdapters2;
        this.resolveDelegate = resolveDelegate2;
        this.variableValues = operationVariables2.valueMap();
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> T readFragment(ResponseField field, Function1<? super ResponseReader, ? extends T> function1) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        Intrinsics.checkParameterIsNotNull(function1, "block");
        return (T) DefaultImpls.readFragment(this, field, function1);
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> List<T> readList(ResponseField field, Function1<? super ResponseReader.ListItemReader, ? extends T> function1) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        Intrinsics.checkParameterIsNotNull(function1, "block");
        return DefaultImpls.readList(this, field, function1);
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> T readObject(ResponseField field, Function1<? super ResponseReader, ? extends T> function1) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        Intrinsics.checkParameterIsNotNull(function1, "block");
        return (T) DefaultImpls.readObject(this, field, function1);
    }

    public final Operation.Variables getOperationVariables() {
        return this.operationVariables;
    }

    public final FieldValueResolver<R> getFieldValueResolver$apollo_runtime() {
        return this.fieldValueResolver;
    }

    public final ScalarTypeAdapters getScalarTypeAdapters$apollo_runtime() {
        return this.scalarTypeAdapters;
    }

    public final ResolveDelegate<R> getResolveDelegate$apollo_runtime() {
        return this.resolveDelegate;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public String readString(ResponseField field) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        String value = (String) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        return value;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public Integer readInt(ResponseField field) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        BigDecimal value = (BigDecimal) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        if (value != null) {
            return Integer.valueOf(value.intValue());
        }
        return null;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public Long readLong(ResponseField field) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        BigDecimal value = (BigDecimal) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        if (value != null) {
            return Long.valueOf(value.longValue());
        }
        return null;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public Double readDouble(ResponseField field) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        BigDecimal value = (BigDecimal) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        if (value != null) {
            return Double.valueOf(value.doubleValue());
        }
        return null;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public Boolean readBoolean(ResponseField field) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        Boolean value = (Boolean) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        return value;
    }

    /* JADX DEBUG: Multi-variable search result rejected for r2v1, resolved type: com.apollographql.apollo.api.internal.ResolveDelegate<R> */
    /* JADX DEBUG: Multi-variable search result rejected for r2v3, resolved type: com.apollographql.apollo.api.internal.ResolveDelegate<R> */
    /* JADX WARN: Multi-variable type inference failed */
    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> T readObject(ResponseField field, ObjectReader<T> objectReader) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        Intrinsics.checkParameterIsNotNull(objectReader, "objectReader");
        T t = null;
        if (shouldSkip(field)) {
            return null;
        }
        Object value = this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        this.resolveDelegate.willResolveObject(field, (R) value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
        } else {
            t = objectReader.read(new RealResponseReader(this.operationVariables, value, this.fieldValueResolver, this.scalarTypeAdapters, this.resolveDelegate));
        }
        ((ResolveDelegate<R>) this.resolveDelegate).didResolveObject(field, (R) value);
        didResolve(field);
        return t;
    }

    /* JADX INFO: Multiple debug info for r10v1 'index$iv$iv'  int: [D('index' int), D('index$iv$iv' int)] */
    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> List<T> readList(ResponseField field, ListReader<T> listReader) {
        List result;
        T t;
        ResponseField responseField = field;
        Intrinsics.checkParameterIsNotNull(responseField, "field");
        Intrinsics.checkParameterIsNotNull(listReader, "listReader");
        if (shouldSkip(field)) {
            return null;
        }
        List values = (List) this.fieldValueResolver.valueFor(this.recordSet, responseField);
        checkValue(responseField, values);
        willResolve(responseField, values);
        if (values == null) {
            this.resolveDelegate.didResolveNull();
            result = null;
        } else {
            List $this$mapIndexed$iv = values;
            Collection destination$iv$iv = new ArrayList(CollectionsKt.collectionSizeOrDefault($this$mapIndexed$iv, 10));
            int index$iv$iv = 0;
            for (Object item$iv$iv : $this$mapIndexed$iv) {
                int index$iv$iv2 = index$iv$iv + 1;
                if (index$iv$iv < 0) {
                    CollectionsKt.throwIndexOverflow();
                }
                this.resolveDelegate.willResolveElement(index$iv$iv);
                if (item$iv$iv == null) {
                    this.resolveDelegate.didResolveNull();
                    t = null;
                } else {
                    t = listReader.read(new ListItemReader(this, responseField, item$iv$iv));
                }
                this.resolveDelegate.didResolveElement(index$iv$iv);
                destination$iv$iv.add(t);
                responseField = field;
                index$iv$iv = index$iv$iv2;
            }
            result = (List) destination$iv$iv;
            this.resolveDelegate.didResolveList(values);
        }
        didResolve(field);
        if (result != null) {
            return Collections.unmodifiableList(result);
        }
        return null;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> T readCustomType(ResponseField.CustomTypeField field) {
        T t;
        Intrinsics.checkParameterIsNotNull(field, "field");
        if (shouldSkip(field)) {
            return null;
        }
        Object value = this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
            t = null;
        } else {
            t = (T) this.scalarTypeAdapters.adapterFor(field.getScalarType()).decode(CustomTypeValue.Companion.fromRawValue(value));
            checkValue(field, t);
            this.resolveDelegate.didResolveScalar(value);
        }
        didResolve(field);
        return t;
    }

    @Override // com.apollographql.apollo.api.internal.ResponseReader
    public <T> T readFragment(ResponseField field, ObjectReader<T> objectReader) {
        Intrinsics.checkParameterIsNotNull(field, "field");
        Intrinsics.checkParameterIsNotNull(objectReader, "objectReader");
        if (shouldSkip(field)) {
            return null;
        }
        String value = (String) this.fieldValueResolver.valueFor(this.recordSet, field);
        checkValue(field, value);
        willResolve(field, value);
        if (value == null) {
            this.resolveDelegate.didResolveNull();
            didResolve(field);
            return null;
        }
        this.resolveDelegate.didResolveScalar(value);
        didResolve(field);
        if (field.getType() != ResponseField.Type.FRAGMENT) {
            return null;
        }
        for (ResponseField.Condition condition : field.getConditions()) {
            if ((condition instanceof ResponseField.TypeNameCondition) && !((ResponseField.TypeNameCondition) condition).getTypeNames().contains(value)) {
                return null;
            }
        }
        return objectReader.read(this);
    }

    private final boolean shouldSkip(ResponseField field) {
        for (ResponseField.Condition condition : field.getConditions()) {
            if (condition instanceof ResponseField.BooleanCondition) {
                Boolean conditionValue = (Boolean) this.variableValues.get(((ResponseField.BooleanCondition) condition).getVariableName());
                if (((ResponseField.BooleanCondition) condition).isInverted()) {
                    if (Intrinsics.areEqual((Object) conditionValue, (Object) true)) {
                        return true;
                    }
                } else if (Intrinsics.areEqual((Object) conditionValue, (Object) false)) {
                    return true;
                }
            }
        }
        return false;
    }

    private final void willResolve(ResponseField field, Object value) {
        this.resolveDelegate.willResolve(field, this.operationVariables, value);
    }

    private final void didResolve(ResponseField field) {
        this.resolveDelegate.didResolve(field, this.operationVariables);
    }

    private final void checkValue(ResponseField field, Object value) {
        if (!(field.getOptional() || value != null)) {
            throw new IllegalStateException(("corrupted response reader, expected non null value for " + field.getFieldName()).toString());
        }
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000V\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0006\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010 \n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0004\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\u0007\u001a\u00020\bH\u0016J\u001f\u0010\t\u001a\u0002H\n\"\b\b\u0001\u0010\n*\u00020\u00052\u0006\u0010\u000b\u001a\u00020\fH\u0016¢\u0006\u0002\u0010\rJ\b\u0010\u000e\u001a\u00020\u000fH\u0016J\b\u0010\u0010\u001a\u00020\u0011H\u0016J(\u0010\u0012\u001a\n\u0012\u0006\u0012\u0004\u0018\u0001H\n0\u0013\"\b\b\u0001\u0010\n*\u00020\u00052\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u0002H\n0\u0015H\u0016J\b\u0010\u0016\u001a\u00020\u0017H\u0016J%\u0010\u0018\u001a\u0002H\n\"\b\b\u0001\u0010\n*\u00020\u00052\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u0002H\n0\u001aH\u0016¢\u0006\u0002\u0010\u001bJ\b\u0010\u001c\u001a\u00020\u001dH\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000¨\u0006\u001e"}, d2 = {"Lcom/apollographql/apollo/internal/response/RealResponseReader$ListItemReader;", "Lcom/apollographql/apollo/api/internal/ResponseReader$ListItemReader;", "field", "Lcom/apollographql/apollo/api/ResponseField;", "value", "", "(Lcom/apollographql/apollo/internal/response/RealResponseReader;Lcom/apollographql/apollo/api/ResponseField;Ljava/lang/Object;)V", "readBoolean", "", "readCustomType", "ExifInterface.GPS_DIRECTION_TRUE", "scalarType", "Lcom/apollographql/apollo/api/ScalarType;", "(Lcom/apollographql/apollo/api/ScalarType;)Ljava/lang/Object;", "readDouble", "", "readInt", "", "readList", "", "listReader", "Lcom/apollographql/apollo/api/internal/ResponseReader$ListReader;", "readLong", "", "readObject", "objectReader", "Lcom/apollographql/apollo/api/internal/ResponseReader$ObjectReader;", "(Lcom/apollographql/apollo/api/internal/ResponseReader$ObjectReader;)Ljava/lang/Object;", "readString", "", "apollo-runtime"}, k = 1, mv = {1, 4, 0})
    /* compiled from: RealResponseReader.kt */
    private final class ListItemReader implements ResponseReader.ListItemReader {
        private final ResponseField field;
        final /* synthetic */ RealResponseReader this$0;
        private final Object value;

        public ListItemReader(RealResponseReader this$02, ResponseField field2, Object value2) {
            Intrinsics.checkParameterIsNotNull(field2, "field");
            Intrinsics.checkParameterIsNotNull(value2, "value");
            this.this$0 = this$02;
            this.field = field2;
            this.value = value2;
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public <T> List<T> readList(Function1<? super ResponseReader.ListItemReader, ? extends T> function1) {
            Intrinsics.checkParameterIsNotNull(function1, "block");
            return DefaultImpls.readList(this, function1);
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public <T> T readObject(Function1<? super ResponseReader, ? extends T> function1) {
            Intrinsics.checkParameterIsNotNull(function1, "block");
            return (T) DefaultImpls.readObject(this, function1);
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public String readString() {
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            Object obj = this.value;
            if (obj != null) {
                return (String) obj;
            }
            throw new TypeCastException("null cannot be cast to non-null type com.kt.String");
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public int readInt() {
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            Object obj = this.value;
            if (obj != null) {
                return ((BigDecimal) obj).intValue();
            }
            throw new TypeCastException("null cannot be cast to non-null type com.apollographql.apollo.api.BigDecimal /* = java.math.BigDecimal */");
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public long readLong() {
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            Object obj = this.value;
            if (obj != null) {
                return ((BigDecimal) obj).longValue();
            }
            throw new TypeCastException("null cannot be cast to non-null type com.apollographql.apollo.api.BigDecimal /* = java.math.BigDecimal */");
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public double readDouble() {
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            Object obj = this.value;
            if (obj != null) {
                return ((BigDecimal) obj).doubleValue();
            }
            throw new TypeCastException("null cannot be cast to non-null type com.apollographql.apollo.api.BigDecimal /* = java.math.BigDecimal */");
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public boolean readBoolean() {
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            Object obj = this.value;
            if (obj != null) {
                return ((Boolean) obj).booleanValue();
            }
            throw new TypeCastException("null cannot be cast to non-null type com.kt.Boolean");
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public <T> T readCustomType(ScalarType scalarType) {
            Intrinsics.checkParameterIsNotNull(scalarType, "scalarType");
            CustomTypeAdapter typeAdapter = this.this$0.getScalarTypeAdapters$apollo_runtime().adapterFor(scalarType);
            this.this$0.getResolveDelegate$apollo_runtime().didResolveScalar(this.value);
            return (T) typeAdapter.decode(CustomTypeValue.Companion.fromRawValue(this.value));
        }

        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public <T> T readObject(ObjectReader<T> objectReader) {
            Intrinsics.checkParameterIsNotNull(objectReader, "objectReader");
            Object value2 = this.value;
            this.this$0.getResolveDelegate$apollo_runtime().willResolveObject(this.field, value2);
            T read = objectReader.read(new RealResponseReader(this.this$0.getOperationVariables(), value2, this.this$0.getFieldValueResolver$apollo_runtime(), this.this$0.getScalarTypeAdapters$apollo_runtime(), this.this$0.getResolveDelegate$apollo_runtime()));
            this.this$0.getResolveDelegate$apollo_runtime().didResolveObject(this.field, value2);
            return read;
        }

        /* JADX INFO: Multiple debug info for r8v1 'index$iv$iv'  int: [D('index' int), D('index$iv$iv' int)] */
        @Override // com.apollographql.apollo.api.internal.ResponseReader.ListItemReader
        public <T> List<T> readList(ListReader<T> listReader) {
            Iterable $this$mapIndexed$iv;
            T t;
            ListReader<T> listReader2 = listReader;
            Intrinsics.checkParameterIsNotNull(listReader2, "listReader");
            Object obj = this.value;
            if (obj != null) {
                List values = (List) obj;
                List $this$mapIndexed$iv2 = values;
                Collection destination$iv$iv = new ArrayList(CollectionsKt.collectionSizeOrDefault($this$mapIndexed$iv2, 10));
                int index$iv$iv = 0;
                for (Object item$iv$iv : $this$mapIndexed$iv2) {
                    int index$iv$iv2 = index$iv$iv + 1;
                    if (index$iv$iv < 0) {
                        CollectionsKt.throwIndexOverflow();
                    }
                    this.this$0.getResolveDelegate$apollo_runtime().willResolveElement(index$iv$iv);
                    if (item$iv$iv == null) {
                        this.this$0.getResolveDelegate$apollo_runtime().didResolveNull();
                        t = null;
                        $this$mapIndexed$iv = $this$mapIndexed$iv2;
                    } else {
                        $this$mapIndexed$iv = $this$mapIndexed$iv2;
                        t = listReader2.read(new ListItemReader(this.this$0, this.field, item$iv$iv));
                    }
                    this.this$0.getResolveDelegate$apollo_runtime().didResolveElement(index$iv$iv);
                    destination$iv$iv.add(t);
                    listReader2 = listReader;
                    index$iv$iv = index$iv$iv2;
                    $this$mapIndexed$iv2 = (List) $this$mapIndexed$iv;
                }
                this.this$0.getResolveDelegate$apollo_runtime().didResolveList(values);
                List<T> unmodifiableList = Collections.unmodifiableList((List) destination$iv$iv);
                Intrinsics.checkExpressionValueIsNotNull(unmodifiableList, "Collections.unmodifiableList(result)");
                return unmodifiableList;
            }
            throw new TypeCastException("null cannot be cast to non-null type com.kt.collections.List<*>");
        }
    }
}
